
#include"SeqList.h"

void Seqtest1()
{
	SL sl;
	//顺序表初始化
	SeqListInit(&sl);
	
	SeqListFrontPush(&sl,1);
	SeqListFrontPush(&sl,2);
	SeqListFrontPush(&sl,3);
	SeqListFrontPush(&sl,4);
	SeqListFrontPush(&sl,5);
	SeqListPrint(&sl);

	SeqListBackPush(&sl,2);
	SeqListBackPush(&sl,3);
	SeqListBackPush(&sl,4);
	SeqListBackPush(&sl,5);
	SeqListBackPush(&sl,6);
	SeqListPrint(&sl);

	SeqListFrontPop(&sl);
	SeqListFrontPop(&sl);
	SeqListFrontPop(&sl);
	SeqListPrint(&sl);

	SeqListFrontPop(&sl);
	SeqListFrontPop(&sl);
	SeqListPrint(&sl);

	SeqListBackPop(&sl);
	SeqListBackPop(&sl);
	SeqListBackPop(&sl);
	SeqListPrint(&sl);

	SeqListBackPop(&sl);
	SeqListBackPop(&sl);
	SeqListPrint(&sl);

	//顺序表的销毁
	SeqListDestory(&sl);
}
void Seqtest2()
{
	SL sl;
	SeqListInit(&sl); 
	
	SeqListInsert(&sl,sl.size,1);
	SeqListInsert(&sl,sl.size,2);
	SeqListInsert(&sl,sl.size,3);
	SeqListInsert(&sl,sl.size,4);
	SeqListInsert(&sl,sl.size,5);
	SeqListPrint(&sl);

	SeqListInsert(&sl,0,6);
	SeqListPrint(&sl);
	SeqListInsert(&sl,2,7);
	SeqListPrint(&sl);
	SeqListInsert(&sl,3,8);
	SeqListPrint(&sl);
	SeqListInsert(&sl,4,9);;
	SeqListPrint(&sl);

	SeqListDelete(&sl,0);
	SeqListPrint(&sl);
	SeqListDelete(&sl,sl.size-1);
	SeqListPrint(&sl);
	SeqListDelete(&sl,2);
	SeqListPrint(&sl);
	SeqListDelete(&sl,3);
	SeqListPrint(&sl);

	SeqListDestory(&sl);
}
void Seqtest3()
{
	SL sl;
	SeqListInit(&sl);
	//插入实验数据
	int i;
	for(i = 0;i<10;i++)
	{
		SeqListBackPush(&sl,i+1);
	}
	SeqListPrint(&sl);
	//查找 + 修改
	for(i = 5;i<13;i++)
	{
		int ret = SeqListFind(&sl,i);
		if(ret >= 0)
		{
			SeqListModify(&sl,ret,i+10);
			SeqListPrint(&sl);
		}
		else
		{
			printf("%s\n","抱歉，没有找到");
		}
	}
	SeqListDestory(&sl);
}
int main()
{
	//Seqtest1();
	//Seqtest2();
	Seqtest3();
	return 0;
}
